package edu.sctu.zcy.month201506.day20150614.iotest;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by user24 on 2015/6/14.
 */
public class InputStreamDemo {

//    List<Integer> list = new ArrayList<>();
    int c = 0;
    int a = 0;
    FileInputStream fileInputStream;
    FileOutputStream fileOutputStream;

    byte[] bytes = new byte[15];
    char[] chars;

    public void input() {

        try {
            fileInputStream = new FileInputStream("D:\\ZCY2\\zcy1.txt");
            fileOutputStream = new FileOutputStream("D:\\ZCY2\\zcy3.txt");

            try {
                while ((c=fileInputStream.read(bytes)) != -1){


                    String s = new String(bytes);//将字节转换为字符串
//                    System.out.println(s);
                    chars = s.toCharArray();//将字符串转换为字符数组输出
//                    System.out.println(chars);
//                    fileOutputStream.write(bytes,0,c);
                }

                CharArrayReader charArrayReader = new CharArrayReader(chars);
                while ((a = charArrayReader.read()) != -1){
                    System.out.print((char)a);
                }


            } catch (IOException e) {
                e.printStackTrace();
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try {
            fileInputStream.close();
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
